home *** CD-ROM | disk | FTP | other *** search
- package javax.swing;
-
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.beans.PropertyChangeListener;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
- import java.util.Hashtable;
- import java.util.Vector;
- import javax.accessibility.Accessible;
- import javax.accessibility.AccessibleContext;
- import javax.accessibility.AccessibleState;
- import javax.swing.event.PopupMenuEvent;
- import javax.swing.event.PopupMenuListener;
- import javax.swing.plaf.PopupMenuUI;
-
- public class JPopupMenu extends JComponent implements Accessible, MenuElement {
- private static final String uiClassID = "PopupMenuUI";
- transient Component invoker;
- transient Popup popup;
- transient Frame frame;
- private String label;
- private boolean paintBorder;
- private Insets margin;
- private int desiredLocationX;
- private int desiredLocationY;
- private int lastPopupType;
- private static final Object heavyPopupCacheKey = new StringBuffer("JPopupMenu.heavyPopupCache");
- private static final Object lightPopupCacheKey = new StringBuffer("JPopupMenu.lightPopupCache");
- private static final Object mediumPopupCacheKey = new StringBuffer("JPopupMenu.mediumPopupCache");
- private static final Object defaultLWPopupEnabledKey = new StringBuffer("JPopupMenu.defaultLWPopupEnabledKey");
- private static final int MAX_CACHE_SIZE = 5;
- private boolean lightWeightPopupEnabled;
- private static final int LIGHT_WEIGHT_POPUP = 0;
- private static final int MEDIUM_WEIGHT_POPUP = 1;
- private static final int HEAVY_WEIGHT_POPUP = 2;
- private SingleSelectionModel selectionModel;
- private static Hashtable listenerRegistry = null;
- private static final Object classLock = new Object();
- // $FF: synthetic field
- static Class class$javax$swing$event$PopupMenuListener;
-
- public JPopupMenu() {
- this((String)null);
- }
-
- public JPopupMenu(String var1) {
- this.label = null;
- this.paintBorder = true;
- this.margin = null;
- this.lastPopupType = 0;
- this.lightWeightPopupEnabled = true;
- this.label = var1;
- this.lightWeightPopupEnabled = getDefaultLightWeightPopupEnabled();
- this.setSelectionModel(new DefaultSingleSelectionModel());
- ((Component)this).addMouseListener(new 2());
- this.updateUI();
- }
-
- // $FF: synthetic method
- static Hashtable access$0() {
- return getHeavyPopupCache();
- }
-
- public JMenuItem add(String var1) {
- return this.add(new JMenuItem(var1));
- }
-
- public JMenuItem add(Action var1) {
- JMenuItem var2 = new JMenuItem((String)var1.getValue("Name"), (Icon)var1.getValue("SmallIcon"));
- ((AbstractButton)var2).setHorizontalTextPosition(4);
- ((AbstractButton)var2).setVerticalTextPosition(0);
- var2.setEnabled(var1.isEnabled());
- ((AbstractButton)var2).addActionListener(var1);
- this.add(var2);
- this.registerMenuItemForAction(var2, var1);
- return var2;
- }
-
- public JMenuItem add(JMenuItem var1) {
- super.add(var1);
- return var1;
- }
-
- public void addPopupMenuListener(PopupMenuListener var1) {
- super.listenerList.add(class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")), var1);
- }
-
- public void addSeparator() {
- ((Container)this).add(new Separator());
- }
-
- boolean alwaysOnTop() {
- return true;
- }
-
- private boolean ancestorIsModalDialog(Component var1) {
- Object var2 = null;
- if (var1 != null) {
- for(Container var3 = var1.getParent(); var3 != null; var3 = ((Component)var3).getParent()) {
- if (var3 instanceof Dialog && ((Dialog)var3).isModal()) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
- }
-
- protected PropertyChangeListener createActionChangeListener(JMenuItem var1) {
- return new ActionChangedListener(this, var1);
- }
-
- private Popup createHeavyWeightPopup() {
- Frame var1 = getFrame(this.invoker);
- if (var1 != null) {
- this.popup = getRecycledHeavyPopup(var1);
- } else {
- var1 = new Frame();
- }
-
- if (this.popup == null) {
- this.popup = new WindowPopup(this, var1);
- }
-
- return this.popup;
- }
-
- private Popup createLightWeightPopup() {
- Object var1 = getRecycledLightPopup();
- if (var1 == null) {
- var1 = new JPanelPopup(this);
- }
-
- return (Popup)var1;
- }
-
- private Popup createMediumWeightPopup() {
- Object var1 = getRecycledMediumPopup();
- if (var1 == null) {
- var1 = new PanelPopup(this);
- }
-
- return (Popup)var1;
- }
-
- protected void firePopupMenuCanceled() {
- Object[] var1 = super.listenerList.getListenerList();
- PopupMenuEvent var2 = null;
-
- for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
- if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
- if (var2 == null) {
- var2 = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)var1[var3 + 1]).popupMenuCanceled(var2);
- }
- }
-
- }
-
- protected void firePopupMenuWillBecomeInvisible() {
- Object[] var1 = super.listenerList.getListenerList();
- PopupMenuEvent var2 = null;
-
- for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
- if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
- if (var2 == null) {
- var2 = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeInvisible(var2);
- }
- }
-
- }
-
- protected void firePopupMenuWillBecomeVisible() {
- Object[] var1 = super.listenerList.getListenerList();
- PopupMenuEvent var2 = null;
-
- for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
- if (var1[var3] == (class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")))) {
- if (var2 == null) {
- var2 = new PopupMenuEvent(this);
- }
-
- ((PopupMenuListener)var1[var3 + 1]).popupMenuWillBecomeVisible(var2);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJPopupMenu(this);
- }
-
- return super.accessibleContext;
- }
-
- public Component getComponent() {
- return this;
- }
-
- public Component getComponentAtIndex(int var1) {
- return ((Container)this).getComponent(var1);
- }
-
- public int getComponentIndex(Component var1) {
- int var2 = ((Container)this).getComponentCount();
- Component[] var3 = ((Container)this).getComponents();
-
- for(int var4 = 0; var4 < var2; ++var4) {
- Component var5 = var3[var4];
- if (var5 == var1) {
- return var4;
- }
- }
-
- return -1;
- }
-
- public static boolean getDefaultLightWeightPopupEnabled() {
- Boolean var0 = (Boolean)SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
- if (var0 == null) {
- SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
- return true;
- } else {
- return var0;
- }
- }
-
- private static Frame getFrame(Component var0) {
- Object var1;
- for(var1 = var0; !(var1 instanceof Frame) && var1 != null; var1 = ((Component)var1).getParent()) {
- }
-
- return (Frame)var1;
- }
-
- private static Hashtable getHeavyPopupCache() {
- Hashtable var0 = (Hashtable)SwingUtilities.appContextGet(heavyPopupCacheKey);
- if (var0 == null) {
- var0 = new Hashtable(2);
- SwingUtilities.appContextPut(heavyPopupCacheKey, var0);
- }
-
- return var0;
- }
-
- public Component getInvoker() {
- return this.invoker;
- }
-
- public String getLabel() {
- return this.label;
- }
-
- private static Vector getLightPopupCache() {
- Vector var0 = (Vector)SwingUtilities.appContextGet(lightPopupCacheKey);
- if (var0 == null) {
- var0 = new Vector();
- SwingUtilities.appContextPut(lightPopupCacheKey, var0);
- }
-
- return var0;
- }
-
- public Insets getMargin() {
- return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
- }
-
- private static Vector getMediumPopupCache() {
- Vector var0 = (Vector)SwingUtilities.appContextGet(mediumPopupCacheKey);
- if (var0 == null) {
- var0 = new Vector();
- SwingUtilities.appContextPut(mediumPopupCacheKey, var0);
- }
-
- return var0;
- }
-
- static Popup getRecycledHeavyPopup(Frame var0) {
- Object var2 = classLock;
- synchronized(var2){}
-
- Popup var1;
- try {
- Hashtable var5 = getHeavyPopupCache();
- if (!var5.containsKey(var0)) {
- var1 = null;
- return var1;
- }
-
- Vector var4 = (Vector)var5.get(var0);
- if (var4.size() <= 0) {
- var1 = null;
- return var1;
- }
-
- Popup var7 = (Popup)var4.elementAt(0);
- var4.removeElementAt(0);
- var1 = var7;
- } catch (Throwable var9) {
- throw var9;
- }
-
- return var1;
- }
-
- static Popup getRecycledLightPopup() {
- Object var1 = classLock;
- synchronized(var1){}
-
- Popup var0;
- try {
- Vector var3 = getLightPopupCache();
- if (var3.size() <= 0) {
- var0 = null;
- return var0;
- }
-
- Popup var5 = (Popup)var3.elementAt(0);
- var3.removeElementAt(0);
- var0 = var5;
- } catch (Throwable var7) {
- throw var7;
- }
-
- return var0;
- }
-
- static Popup getRecycledMediumPopup() {
- Object var1 = classLock;
- synchronized(var1){}
-
- Popup var0;
- try {
- Vector var3 = getMediumPopupCache();
- if (var3.size() <= 0) {
- var0 = null;
- return var0;
- }
-
- Popup var5 = (Popup)var3.elementAt(0);
- var3.removeElementAt(0);
- var0 = var5;
- } catch (Throwable var7) {
- throw var7;
- }
-
- return var0;
- }
-
- JPopupMenu getRootPopupMenu() {
- JPopupMenu var1;
- for(var1 = this; var1 != null && !var1.isPopupMenu() && var1.getInvoker() != null && var1.getInvoker().getParent() != null && var1.getInvoker().getParent() instanceof JPopupMenu; var1 = (JPopupMenu)var1.getInvoker().getParent()) {
- }
-
- return var1;
- }
-
- public SingleSelectionModel getSelectionModel() {
- return this.selectionModel;
- }
-
- public MenuElement[] getSubElements() {
- Vector var2 = new Vector();
- int var3 = ((Container)this).getComponentCount();
-
- for(int var4 = 0; var4 < var3; ++var4) {
- Component var5 = ((Container)this).getComponent(var4);
- if (var5 instanceof MenuElement) {
- var2.addElement(var5);
- }
- }
-
- MenuElement[] var1 = new MenuElement[var2.size()];
- int var7 = 0;
-
- for(int var6 = var2.size(); var7 < var6; ++var7) {
- var1[var7] = (MenuElement)var2.elementAt(var7);
- }
-
- return var1;
- }
-
- public PopupMenuUI getUI() {
- return (PopupMenuUI)super.ui;
- }
-
- public String getUIClassID() {
- return "PopupMenuUI";
- }
-
- public void insert(Component var1, int var2) {
- if (var2 < 0) {
- throw new IllegalArgumentException("index less than zero.");
- } else {
- int var3 = ((Container)this).getComponentCount();
- Vector var4 = new Vector();
-
- for(int var5 = var2; var5 < var3; ++var5) {
- var4.addElement(((Container)this).getComponent(var2));
- this.remove(var2);
- }
-
- ((Container)this).add(var1);
-
- for(int var6 = 0; var6 < var4.size(); ++var6) {
- ((Container)this).add((Component)var4.elementAt(var6));
- }
-
- }
- }
-
- public void insert(Action var1, int var2) {
- throw new Error("void insert(Action, int) {} not yet implemented");
- }
-
- private boolean invokerInHeavyWeightPopup(Component var1) {
- if (var1 != null) {
- for(Container var2 = var1.getParent(); var2 != null; var2 = ((Component)var2).getParent()) {
- if (var2 instanceof WindowPopup) {
- return true;
- }
-
- if (var2 instanceof PanelPopup || var2 instanceof JPanelPopup) {
- break;
- }
- }
- }
-
- return false;
- }
-
- public boolean isBorderPainted() {
- return this.paintBorder;
- }
-
- public boolean isLightWeightPopupEnabled() {
- return this.lightWeightPopupEnabled;
- }
-
- private boolean isPopupMenu() {
- return this.invoker != null && !(this.invoker instanceof JMenu);
- }
-
- boolean isSubPopupMenu(JPopupMenu var1) {
- int var2 = ((Container)this).getComponentCount();
- Component[] var3 = ((Container)this).getComponents();
-
- for(int var4 = 0; var4 < var2; ++var4) {
- Component var5 = var3[var4];
- if (var5 instanceof JMenu) {
- JMenu var6 = (JMenu)var5;
- JPopupMenu var7 = var6.getPopupMenu();
- if (var7 == var1) {
- return true;
- }
-
- if (var7.isSubPopupMenu(var1)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public boolean isVisible() {
- return this.popup != null ? this.popup.isShowing() : false;
- }
-
- public void menuSelectionChanged(boolean var1) {
- if (this.invoker instanceof JMenu) {
- JMenu var2 = (JMenu)this.invoker;
- if (var1) {
- var2.setPopupMenuVisible(true);
- } else {
- var2.setPopupMenuVisible(false);
- }
- }
-
- if (this.isPopupMenu() && !var1) {
- this.setVisible(false);
- }
-
- }
-
- public void pack() {
- if (this.popup != null) {
- this.popup.pack();
- }
-
- }
-
- protected void paintBorder(Graphics var1) {
- if (this.isBorderPainted()) {
- super.paintBorder(var1);
- }
-
- }
-
- protected String paramString() {
- String var1 = this.label != null ? this.label : "";
- String var2 = this.paintBorder ? "true" : "false";
- String var3 = this.margin != null ? this.margin.toString() : "";
- String var4;
- if (this.lastPopupType == 0) {
- var4 = "LIGHT_WEIGHT_POPUP";
- } else if (this.lastPopupType == 1) {
- var4 = "MEDIUM_WEIGHT_POPUP";
- } else if (this.lastPopupType == 2) {
- var4 = "HEAVY_WEIGHT_POPUP";
- } else {
- var4 = "";
- }
-
- String var5 = this.lightWeightPopupEnabled ? "true" : "false";
- return super.paramString() + ",desiredLocationX=" + this.desiredLocationX + ",desiredLocationY=" + this.desiredLocationY + ",label=" + var1 + ",lastPopupType=" + var4 + ",lightWeightPopupEnabled=" + var5 + ",margin=" + var3 + ",paintBorder=" + var2;
- }
-
- private boolean popupFit(Rectangle var1) {
- if (this.invoker != null) {
- for(Container var2 = this.invoker.getParent(); var2 != null; var2 = ((Component)var2).getParent()) {
- if (var2 instanceof JFrame || var2 instanceof JDialog || var2 instanceof JWindow) {
- return SwingUtilities.isRectangleContainingRectangle(((Component)var2).getBounds(), var1);
- }
-
- if (var2 instanceof JApplet) {
- Rectangle var3 = ((Component)var2).getBounds();
- Point var4 = ((Component)var2).getLocationOnScreen();
- var3.x = var4.x;
- var3.y = var4.y;
- return SwingUtilities.isRectangleContainingRectangle(var3, var1);
- }
-
- if (var2 instanceof Frame) {
- return SwingUtilities.isRectangleContainingRectangle(((Component)var2).getBounds(), var1);
- }
- }
- }
-
- return false;
- }
-
- public void processKeyEvent(KeyEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
- }
-
- public void processMouseEvent(MouseEvent var1, MenuElement[] var2, MenuSelectionManager var3) {
- }
-
- private void readObject(ObjectInputStream var1) throws IOException, ClassNotFoundException {
- var1.defaultReadObject();
- Vector var2 = (Vector)var1.readObject();
- int var3 = 0;
- int var4 = var2.size();
- if (var3 < var4 && var2.elementAt(var3).equals("invoker")) {
- ++var3;
- this.invoker = (Component)var2.elementAt(var3);
- ++var3;
- }
-
- if (var3 < var4 && var2.elementAt(var3).equals("popup")) {
- ++var3;
- this.popup = (Popup)var2.elementAt(var3);
- ++var3;
- }
-
- if (var3 < var4 && var2.elementAt(var3).equals("frame")) {
- ++var3;
- this.frame = (Frame)var2.elementAt(var3);
- ++var3;
- }
-
- }
-
- static void recycleHeavyPopup(Popup var0) {
- Object var1 = classLock;
- synchronized(var1){}
-
- try {
- Frame var4 = getFrame((Component)var0);
- Hashtable var5 = getHeavyPopupCache();
- Vector var3;
- if (var5.containsKey(var4)) {
- var3 = (Vector)var5.get(var4);
- } else {
- var3 = new Vector();
- var5.put(var4, var3);
- ((Window)var4).addWindowListener(new 1(var4));
- }
-
- if (var3.size() < 5) {
- var3.addElement(var0);
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- static void recycleLightPopup(Popup var0) {
- Object var1 = classLock;
- synchronized(var1){}
-
- try {
- Vector var3 = getLightPopupCache();
- if (var3.size() < 5) {
- var3.addElement(var0);
- }
- } catch (Throwable var5) {
- throw var5;
- }
-
- }
-
- static void recycleMediumPopup(Popup var0) {
- Object var1 = classLock;
- synchronized(var1){}
-
- try {
- Vector var3 = getMediumPopupCache();
- if (var3.size() < 5) {
- var3.addElement(var0);
- }
- } catch (Throwable var5) {
- throw var5;
- }
-
- }
-
- static void recyclePopup(Popup var0) {
- if (var0 instanceof JPanelPopup) {
- recycleLightPopup(var0);
- } else if (var0 instanceof WindowPopup) {
- recycleHeavyPopup(var0);
- } else if (var0 instanceof PanelPopup) {
- recycleMediumPopup(var0);
- }
-
- }
-
- private void registerMenuItemForAction(JMenuItem var1, Action var2) {
- PropertyChangeListener var3 = this.createActionChangeListener(var1);
- if (listenerRegistry == null) {
- listenerRegistry = new Hashtable();
- }
-
- listenerRegistry.put(var1, var3);
- listenerRegistry.put(var3, var2);
- var2.addPropertyChangeListener(var3);
- }
-
- public void remove(int var1) {
- if (var1 < 0) {
- throw new IllegalArgumentException("index less than zero.");
- } else if (var1 > ((Container)this).getComponentCount() - 1) {
- throw new IllegalArgumentException("index greater than the number of items.");
- } else {
- Component var2 = ((Container)this).getComponent(var1);
- if (var2 instanceof JMenuItem) {
- this.unregisterMenuItemForAction((JMenuItem)var2);
- }
-
- super.remove(var1);
- }
- }
-
- public void remove(Component var1) {
- super.remove(var1);
- if (var1 instanceof JMenuItem) {
- JMenuItem var2 = (JMenuItem)var1;
- this.unregisterMenuItemForAction(var2);
- }
-
- }
-
- public void removePopupMenuListener(PopupMenuListener var1) {
- super.listenerList.remove(class$javax$swing$event$PopupMenuListener != null ? class$javax$swing$event$PopupMenuListener : (class$javax$swing$event$PopupMenuListener = class$("javax.swing.event.PopupMenuListener")), var1);
- }
-
- private void replacePopup(int var1) {
- this.popup.removeComponent(this);
- recyclePopup(this.popup);
- this.popup = null;
- switch (var1) {
- case 0:
- this.popup = this.createLightWeightPopup();
- break;
- case 1:
- this.popup = this.createMediumWeightPopup();
- break;
- case 2:
- this.popup = this.createHeavyWeightPopup();
- }
-
- this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
- this.popup.addComponent(this, "Center");
- ((Container)this).invalidate();
- this.popup.setBackground(((Component)this).getBackground());
- this.popup.pack();
- }
-
- public void setBorderPainted(boolean var1) {
- this.paintBorder = var1;
- ((Component)this).repaint();
- }
-
- public static void setDefaultLightWeightPopupEnabled(boolean var0) {
- SwingUtilities.appContextPut(defaultLWPopupEnabledKey, new Boolean(var0));
- }
-
- public void setInvoker(Component var1) {
- Component var2 = this.invoker;
- this.invoker = var1;
- if (var2 != this.invoker && super.ui != null) {
- super.ui.uninstallUI(this);
- super.ui.installUI(this);
- }
-
- ((Container)this).invalidate();
- }
-
- public void setLabel(String var1) {
- String var2 = this.label;
- this.label = var1;
- ((JComponent)this).firePropertyChange("label", var2, var1);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleVisibleData", var2, var1);
- }
-
- ((Container)this).invalidate();
- ((Component)this).repaint();
- }
-
- public void setLightWeightPopupEnabled(boolean var1) {
- this.lightWeightPopupEnabled = var1;
- }
-
- public void setLocation(int var1, int var2) {
- if (this.popup != null) {
- this.popup.setLocationOnScreen(var1, var2);
- } else {
- this.desiredLocationX = var1;
- this.desiredLocationY = var2;
- }
-
- }
-
- public void setPopupSize(int var1, int var2) {
- if (this.popup != null) {
- this.popup.setSize(var1, var2);
- }
-
- }
-
- public void setPopupSize(Dimension var1) {
- if (this.popup != null) {
- this.popup.setSize(var1.width, var1.height);
- }
-
- }
-
- public void setSelected(Component var1) {
- SingleSelectionModel var2 = this.getSelectionModel();
- int var3 = this.getComponentIndex(var1);
- var2.setSelectedIndex(var3);
- }
-
- public void setSelectionModel(SingleSelectionModel var1) {
- this.selectionModel = var1;
- }
-
- public void setUI(PopupMenuUI var1) {
- super.setUI(var1);
- }
-
- public void setVisible(boolean var1) {
- if (var1 != this.isVisible()) {
- if (!var1) {
- this.getSelectionModel().clearSelection();
- } else if (this.isPopupMenu()) {
- if (this.getSubElements().length > 0) {
- MenuElement[] var2 = new MenuElement[]{this, this.getSubElements()[0]};
- MenuSelectionManager.defaultManager().setSelectedPath(var2);
- } else {
- MenuElement[] var6 = new MenuElement[]{this};
- MenuSelectionManager.defaultManager().setSelectedPath(var6);
- }
- }
-
- if (var1) {
- boolean var4 = this.ancestorIsModalDialog(this.invoker);
- this.firePopupMenuWillBecomeVisible();
- switch (this.lastPopupType) {
- case 0:
- this.popup = this.createLightWeightPopup();
- break;
- case 1:
- this.popup = this.createMediumWeightPopup();
- break;
- case 2:
- this.popup = this.createHeavyWeightPopup();
- }
-
- int var7 = this.lastPopupType;
- this.popup.setLocationOnScreen(this.desiredLocationX, this.desiredLocationY);
- this.popup.addComponent(this, "Center");
- this.popup.setBackground(((Component)this).getBackground());
- this.popup.pack();
- Rectangle var5 = new Rectangle(this.desiredLocationX, this.desiredLocationY, this.popup.getWidth(), this.popup.getHeight());
- byte var3;
- if (this.popupFit(var5)) {
- if (this.lightWeightPopupEnabled) {
- var3 = 0;
- } else {
- var3 = 1;
- }
- } else if (var4) {
- var3 = 1;
- } else {
- var3 = 2;
- }
-
- if (this.invokerInHeavyWeightPopup(this.invoker)) {
- var3 = 2;
- }
-
- if (this.invoker == null) {
- var3 = 2;
- }
-
- if (var3 != var7) {
- this.replacePopup(var3);
- var7 = var3;
- }
-
- this.lastPopupType = var7;
- this.popup.show(this.invoker);
- } else if (this.popup != null) {
- this.firePopupMenuWillBecomeInvisible();
- this.popup.hide();
- this.popup.removeComponent(this);
- recyclePopup(this.popup);
- this.popup = null;
- }
-
- if (super.accessibleContext != null) {
- if (var1) {
- super.accessibleContext.firePropertyChange("AccessibleState", (Object)null, AccessibleState.VISIBLE);
- } else {
- super.accessibleContext.firePropertyChange("AccessibleState", AccessibleState.VISIBLE, (Object)null);
- }
- }
-
- }
- }
-
- public void show(Component var1, int var2, int var3) {
- this.setInvoker(var1);
- Frame var4 = getFrame(var1);
- if (var4 != this.frame && var4 != null) {
- this.frame = var4;
- if (this.popup != null) {
- this.setVisible(false);
- }
- }
-
- if (var1 != null) {
- Point var5 = var1.getLocationOnScreen();
- this.setLocation(var5.x + var2, var5.y + var3);
- } else {
- this.setLocation(var2, var3);
- }
-
- this.setVisible(true);
- }
-
- private void unregisterMenuItemForAction(JMenuItem var1) {
- if (listenerRegistry != null) {
- ActionChangedListener var2 = (ActionChangedListener)listenerRegistry.remove(var1);
- if (var2 != null) {
- Action var3 = (Action)listenerRegistry.remove(var2);
- if (var3 != null) {
- ((AbstractButton)var1).removeActionListener(var3);
- var3.removePropertyChangeListener(var2);
- }
-
- var2.setTarget((JMenuItem)null);
- }
- }
-
- }
-
- public void updateUI() {
- this.setUI((PopupMenuUI)UIManager.getUI(this));
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- Vector var2 = new Vector();
- var1.defaultWriteObject();
- if (this.invoker != null && this.invoker instanceof Serializable) {
- var2.addElement("invoker");
- var2.addElement(this.invoker);
- }
-
- if (this.popup != null && this.popup instanceof Serializable) {
- var2.addElement("popup");
- var2.addElement(this.popup);
- }
-
- if (this.frame != null && this.frame instanceof Serializable) {
- var2.addElement("frame");
- var2.addElement(this.frame);
- }
-
- var1.writeObject(var2);
- if (super.ui != null && this.getUIClassID().equals("PopupMenuUI")) {
- super.ui.installUI(this);
- }
-
- }
- }
-